package com.greenx.hello;

/**
 * 
 * @author Stephen Xianwei Zhang
 * 
 */
public class HelloException {

    public static void main(String[] args) {
        // testIllegalArgumentException();
        try {
            testExceptionOrder();
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }

    /**
     * 
     * @throws IllegalArgumentException
     */
    public static void testIllegalArgumentException() throws IllegalArgumentException {
        throw new IllegalArgumentException("testIllegalArgumentException.");
    }

    /**
     * 
     * @throws Exception
     */
    public static void testThrowsException() throws Exception {

        int i = 0;
        int j = 20;
        System.out.println(j / i);

    }

    private static void testExceptionOrder() {

        try {
            int i = 0;
            int j = 20;
            System.out.println(j / i);
        } catch (java.lang.ArithmeticException ae) {
            System.out.println(ae.getMessage());
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }
}
